﻿<Controls:MetroWindow 
    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"        
        xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"  
        x:Class="EmailClient.View.LetterView"
        EnableDWMDropShadow="True"
        ResizeMode="CanResizeWithGrip"
        WindowTransitionsEnabled="False"
        WindowStartupLocation="CenterScreen"
        Title="" Height="480" Width="640" Closed="MetroWindow_Closed">

    <Controls:MetroWindow.LeftWindowCommands>
        <Controls:WindowCommands>
            <Button x:Name="btSend" Click="SentLetter"
                    ToolTip="{DynamicResource EmailSendButtonTip}"
                    Content="{DynamicResource EmailSendButtonName}" />
            <Button x:Name="btForward" Click="ForwardLetter"
                    ToolTip="{DynamicResource EmailForwardButtonTip}"
                    Content="{DynamicResource EmailForwardButtonName}" 
                    Visibility="Collapsed"/>
            <Button x:Name="btAddAtt" Click="AddAttachment"
                    ToolTip="{DynamicResource EmailAttachFilesButtonTip}"
                    Content="{DynamicResource EmailAttachFilesButtonName}" />
            <Button x:Name="btMoveLetter" Click="MoveLetter"
                    ToolTip="{DynamicResource EmailMoveEmailButtonTip}"
                    Content="{DynamicResource EmailMoveEmailButtonName}" />
            <ComboBox x:Name="cbFolders"
                    ItemsSource="{Binding folders}" 
                    DisplayMemberPath="Name"
                    Visibility="Collapsed" SelectionChanged="cbFolders_SelectionChanged"/>
            <!--<Button x:Name="btClose" Click="CloseLetter"
                    ToolTip="{DynamicResource EmailCloseButtonTip}"
                    Content="{DynamicResource EmailCloseButtonName}" />-->
        </Controls:WindowCommands>
    </Controls:MetroWindow.LeftWindowCommands>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        
        <StackPanel x:Name="spMain" Grid.Row="0" Orientation="Vertical">

            <TextBlock HorizontalAlignment="Left"  VerticalAlignment="Center" Margin="5,0,0,5" ><Run Text="{DynamicResource EmailToTextBox}"/></TextBlock>
            <TextBox x:Name="tbSentTo"  Text="{Binding ToSent, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True}" Margin="5,0"/>

            <TextBlock  HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,5" ><Run Text="{DynamicResource EmailSubjectTextBox}"/></TextBlock>
            <TextBox x:Name="tbSubject"  Text="{Binding Subject, UpdateSourceTrigger=PropertyChanged}" Margin="5,0"/>

            <StackPanel x:Name="spCC">
                <TextBlock VerticalAlignment="Center" Margin="5,0,0,5" ><Run Text="{DynamicResource EmailCCTextBox}"/></TextBlock>
                <TextBox x:Name="tbCC" Text="{Binding CC, UpdateSourceTrigger=PropertyChanged}" Margin="5,0"/>
            </StackPanel>

            <StackPanel x:Name="spBCC">
                <TextBlock  HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,5"><Run Text="{DynamicResource EmailBCCTextBox}"/></TextBlock>
                <TextBox x:Name="tbBCC" Text="{Binding Bcc, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,5,10"/>
            </StackPanel>

            <ListView x:Name="lvAttachments" Margin="5" BorderThickness="1" Visibility="Collapsed">
                <ListView.ContextMenu>
                    <ContextMenu>
                        <MenuItem x:Name="cmiSave" Header="{DynamicResource EmailSaveContextMenu}" 
                        Command="{Binding SaveItem}"
                        CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}" Click="SaveItem_Click" />
                        <MenuItem x:Name="cmiDel" Header="{DynamicResource EmailDeleteContextMenu}" 
                        Command="{Binding RemoveItem}"
                        CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}" Click="DelItem_Click" />                        
                    </ContextMenu>
                </ListView.ContextMenu>
            </ListView>
        </StackPanel>

        <xctk:RichTextBox x:Name="Body" Grid.Row="1" Margin="2">
            <xctk:RichTextBoxFormatBarManager.FormatBar>
                <xctk:RichTextBoxFormatBar />
            </xctk:RichTextBoxFormatBarManager.FormatBar>
            <xctk:RichTextBox.TextFormatter>
                <xctk:RtfFormatter />
            </xctk:RichTextBox.TextFormatter>
        </xctk:RichTextBox>

        <WebBrowser x:Name="wbBody" Grid.Row="1" Visibility="Hidden"/>        
    </Grid>

</Controls:MetroWindow>
